# -*- coding: utf-8 -*-
from zope.lifecycleevent import IObjectModifiedEvent
from zope.interface import Interface, Attribute

###############################################################################
##
## Models
##
###############################################################################

class IContainer(Interface):
    """
    Can contain other objects.
    """
    ## TODO - should define dome methods


class IContent(Interface):
    """
    Base interface for all content objects.
    """
    uid = Attribute(u'Unique content identifier')


class ISite(IContent):
    """
    Content object model: Site
    """


class IFolder(IContent):
    """
    Content object model: Folder
    """


class IDocument(IContent):
    """
    Content object model: Document
    """
    text = Attribute(u'Document text')


class IFile(IContent):
    """
    Content object model: File
    """
    file = Attribute(u'File data')


class IImage(IFile):
    """
    Content object model: Image
    """


class ILink(IContent):
    """
    Content object model: Link
    """
    url = Attribute(u'URL')
    
   
###############################################################################
##
## Events
##
###############################################################################

class IContainerModifiedEvent(IObjectModifiedEvent):
    """
    The container has been modified.

    This event is specific to "containerness" modifications, which means
    addition, removal or reordering of sub-objects.
    """


class INewLocalSite(Interface):
    """
    Event: a local site was created
    """
    manager = Attribute(u'The new site manager')


###############################################################################
##
## Adapters
##
###############################################################################

class IOrdering(Interface):
    """
    An adapter providing ordering operations on its context.
    """

    def notifyAdded(id):
        """
        Inform the ordering implementation that an item was added.
        """

    def notifyRemoved(id):
        """
        Inform the ordering implementation that an item was removed.
        """

    def getObjectPosition(id):
        """
        Get the position of the given id.
        """

    def idsInOrder():
        """
        Return all object ids, in the correct order.
        """

    def iterIdsInOrder():
        """
        Iterate over all object ids, in the correct order.
        """

    def moveObjectsByDelta(ids, delta, subset_ids=None, suppress_events=False):
        """
        Move the specified ids (a sequence, or a single string id)
        by the given delta (a positive or negative number). By
        default, this moves the objects within the whole set of
        sub-items in the context container, but if subset_ids is
        specified, it gives a subset of ids to consider.
        Should return the number of objects that changed position.
        """

    def moveObjectsUp(ids, delta=1, subset_ids=None):
        """
        Move specified sub-objects up by delta in container.
        """

    def moveObjectsDown(ids, delta=1, subset_ids=None):
        """
        Move specified sub-objects down by delta in container.
        """

    def moveObjectsToTop(ids, subset_ids=None):
        """
        Move specified sub-objects to top of container.
        """

    def moveObjectsToBottom(ids, subset_ids=None):
        """
        Move specified sub-objects to bottom of container.
        """

    def moveObjectToPosition(id, position, suppress_events=False):
        """
        Move specified object to absolute position.
        """

    def orderObjects(key, reverse=None):
        """
        Order sub-objects by key and direction.
        """


class IContentImporter(Interface):
    """
    An adapter providing import functionality.
    """

    def do_import(filename):
        """
        Import content from given file.
        """


class IAbsoluteURL(Interface):

    def url():
        """
        Absolute URL of context. 
        """
